package com.xhcl.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.xhcl.common.annotation.Log;
import com.xhcl.common.enums.BusinessType;
import com.xhcl.system.domain.TSrhsIncomemx;
import com.xhcl.system.service.ITSrhsIncomemxService;
import com.xhcl.web.controller.common.CommonController;
import com.xhcl.common.core.controller.BaseController;
import com.xhcl.common.core.domain.AjaxResult;
import com.xhcl.framework.uitls.poi.ExcelUtil;
import com.xhcl.common.core.page.TableDataInfo;

/**
 * 收入情况明细Controller
 * 
 * @author xhcl
 * @date 2020-09-02
 */
@Controller
@RequestMapping("/system/incomemx")
public class TSrhsIncomemxController extends BaseController
{
	private static final Logger log = LoggerFactory.getLogger(TSrhsIncomemxController.class);
	
	private String prefix = "system/incomemx";

    @Autowired
    private ITSrhsIncomemxService tSrhsIncomemxService;

    @RequiresPermissions("system:incomemx:view")
    @GetMapping()
    public String incomemx(ModelMap mmap)
    {
    	mmap.put("lsh", "");
        return prefix + "/incomemx";
    }

    /**
     * 查询收入情况明细列表
     */
    @RequiresPermissions("system:incomemx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSrhsIncomemx tSrhsIncomemx)
    { 
    	log.info("请求参数:"+JSON.toJSONString(tSrhsIncomemx));
        startPage();
        List<TSrhsIncomemx> list = tSrhsIncomemxService.selectTSrhsIncomemxList(tSrhsIncomemx);
        log.info("请求返回结果 :"+JSON.toJSONString(list));
        return getDataTable(list);
    }

    /**
     * 导出收入情况明细列表
     */
    @RequiresPermissions("system:incomemx:export")
    @Log(title = "收入情况明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSrhsIncomemx tSrhsIncomemx)
    {
        List<TSrhsIncomemx> list = tSrhsIncomemxService.selectTSrhsIncomemxList(tSrhsIncomemx);
        ExcelUtil<TSrhsIncomemx> util = new ExcelUtil<TSrhsIncomemx>(TSrhsIncomemx.class);
        return util.exportExcel(list, "incomemx");
    }

    /**
     * 新增收入情况明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存收入情况明细
     */
    @RequiresPermissions("system:incomemx:add")
    @Log(title = "收入情况明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSrhsIncomemx tSrhsIncomemx)
    {
        return toAjax(tSrhsIncomemxService.insertTSrhsIncomemx(tSrhsIncomemx));
    }

    /**
     * 修改收入情况明细
     */
    @GetMapping("/edit/{lsh}")
    public String edit(@PathVariable("lsh") String lsh, ModelMap mmap)
    {
        TSrhsIncomemx tSrhsIncomemx = tSrhsIncomemxService.selectTSrhsIncomemxById(lsh);
        mmap.put("tSrhsIncomemx", tSrhsIncomemx);
        return prefix + "/edit";
    }

    /**
     * 修改保存收入情况明细
     */
    @RequiresPermissions("system:incomemx:edit")
    @Log(title = "收入情况明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSrhsIncomemx tSrhsIncomemx)
    {
        return toAjax(tSrhsIncomemxService.updateTSrhsIncomemx(tSrhsIncomemx));
    }

    /**
     * 删除收入情况明细
     */
    @RequiresPermissions("system:incomemx:remove")
    @Log(title = "收入情况明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tSrhsIncomemxService.deleteTSrhsIncomemxByIds(ids));
    }
}
